const express = require("express");
const app = express();
const heros = require("./routes/heros")
const users = require("./routes/users")
const jwt = require("express-jwt");

// 处理post请求的参数
app.use(express.urlencoded());

// 验证 token的设置
// secret 密钥 
// algorithms 加密和解密的算法 不用动它 
// unless 那些接口不用验证token 
app.use(jwt({ secret: 'itcast', algorithms: ['HS256'] }).unless({ path: ['/users/login', "/users/register"] }));


app.use("/heros", heros);
app.use("/users", users);

app.listen(8000, () => {
  console.log("8000 开启成功");
})